package cn.ming.wfchat.app;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.google.gson.JsonObject;

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.ming.wfchat.app.dynamic.bean.NetWorkCountBean;
import cn.ming.wfchat.app.dynamic.bean.RateBean;
import cn.ming.wfchat.app.dynamic.bean.ValidateNetWorkBean;
import cn.ming.wfchat.app.login.model.LoginPhoneResult;
import cn.ming.wfchat.app.login.model.LoginResult;
import cn.ming.wfchat.app.login.model.PCSession;
import cn.ming.wfchat.app.main.ConfigFindBean;
import cn.ming.wfchat.app.main.SplashActivity;
import cn.ming.wfchat.app.me.activity.model.AssetsBean;
import cn.ming.wfchat.app.me.activity.model.CertificationListbean;
import cn.ming.wfchat.app.me.activity.model.ConstListbean;
import cn.ming.wfchat.app.me.activity.model.DynamicsCommentsBean;
import cn.ming.wfchat.app.me.activity.model.EarningsRecordBean;
import cn.ming.wfchat.app.me.activity.model.MoneyFlowingWaterBean;
import cn.ming.wfchat.app.me.activity.model.RechargeBean;
import cn.ming.wfchat.app.me.activity.model.RedPageListBean;
import cn.ming.wfchat.app.me.activity.model.ToWithdrawalBean;
import cn.ming.wfchat.app.me.activity.model.TransferAccoountBean;
import cn.ming.wfchat.app.me.activity.model.TransferAccountDetailBean;
import cn.ming.wfchat.app.me.activity.model.VersionBean;
import cn.ming.wfchat.app.me.activity.model.WithdrawalRecordBean;
import cn.ming.wfchat.app.moment.third.beans.BuddyBean;
import cn.ming.wfchat.app.moment.third.beans.Feed;
import cn.ming.wfchat.app.moment.third.beans.UserBean;
import cn.ming.wfchat.kit.AppServiceProvider;
import cn.ming.wfchat.kit.ChatManagerHolder;
import cn.ming.wfchat.kit.Config;
import cn.ming.wfchat.kit.group.GroupAnnouncement;
import cn.ming.wfchat.kit.net.OKHttpHelper;
import cn.ming.wfchat.kit.net.OKHttpHelper2;
import cn.ming.wfchat.kit.net.SimpleCallback;
import cn.ming.wfchat.kit.net.base.StatusResult;
import cn.ming.wfchat.kit.net.base.StatusResult2;
import cn.wildfirechat.remote.ChatManager;
import okhttp3.MediaType;

public class AppService implements AppServiceProvider {
    private static AppService Instance = new AppService();
    private static int OUTEXIT = -200;


    private AppService() {

    }

    public static AppService Instance() {
        return Instance;
    }

    public interface FailureCallback {

        void onUiFailure(int code, String msg);
    }

    public interface LoginCallback extends FailureCallback {
        void onUiSuccess(LoginResult loginResult);

    }

    public interface OphoneCallback extends FailureCallback {
        void onUiSuccess(LoginPhoneResult result);
    }

    public interface PCLoginCallback extends FailureCallback {
        void onUiSuccess();
    }

    public interface RechargeCallback extends FailureCallback {
        void onUiSuccess(RechargeBean rechargeBean);

    }

    public interface ToWithdrawalCallback extends FailureCallback {
        void onUiSuccess(ToWithdrawalBean rechargeBean);

    }

    public interface TransferAccoountCallback extends FailureCallback {
        void onUiSuccess(TransferAccoountBean rechargeBean);

    }

    public interface RedPageListCallback extends FailureCallback {
        void onUiSuccess(RedPageListBean redPageListBean);

    }

    public interface ConstListCallback extends FailureCallback {
        void onUiSuccess(ConstListbean redPageListBean);

    }

    public interface CertificationListCallback extends FailureCallback {
        void onUiSuccess(CertificationListbean certificationListbean);

    }


    public interface FindDynamicsRateCallback extends FailureCallback {
        void onUiSuccess(RateBean assetsBean);

    }

    public interface FindNetWorkCallback extends FailureCallback {
        void onUiSuccess(ValidateNetWorkBean assetsBean);

    }

    public interface AssetsCCallback extends FailureCallback {
        void onUiSuccess(AssetsBean assetsBean);

    }

    public interface DynamicsReplyCallback extends FailureCallback {
        void onUiSuccess(DynamicsCommentsBean assetsBean);

    }

    public interface ReleaseDynamicsCallback extends FailureCallback {
        void onUiSuccess(StatusResult assetsBean);

        void onUiFailure(int code, String msg);
    }

    public interface FindDynamicCallback extends FailureCallback {
        void onUiSuccess(Feed assetsBean);

    }

    public interface logCallback extends FailureCallback {
        void onUiSuccess(MoneyFlowingWaterBean assetsBean);

    }

    public interface withdrawalRecordCallback extends FailureCallback {
        void onUiSuccess(WithdrawalRecordBean assetsBean);

    }

    public interface coinLogCallback extends FailureCallback {
        void onUiSuccess(EarningsRecordBean assetsBean);

    }

    public interface DynamicsLikesCallback extends FailureCallback {
        void onUiSuccess(StatusResult assetsBean);

    }

    public interface InfoByMobileCallback extends FailureCallback {
        void onUiSuccess(UserBean assetsBean);

    }

    public interface FindNetWorkCountCallback extends FailureCallback {
        void onUiSuccess(NetWorkCountBean assetsBean);

    }

    public interface BuddyNetWorkCallback extends FailureCallback {
        void onUiSuccess(BuddyBean assetsBean);

    }

    public interface ConfigFindCallback extends FailureCallback {
        void onUiSuccess(ConfigFindBean assetsBean);

    }

    public interface ChackVersionCallback extends FailureCallback {
        void onUiSuccess(VersionBean assetsBean);

    }

    public interface TransferAccountDetailCallback extends FailureCallback {
        void onUiSuccess(TransferAccountDetailBean assetsBean);

    }


    public interface SendRedPageCallback extends FailureCallback {
        void onUiSuccess(StatusResult result);

    }

    public interface SendCodeCallback {
        void onUiSuccess();

        void onUiFailure(String msg);
    }

    public interface ScanPCCallback {
        void onUiSuccess(PCSession pcSession);

        void onUiFailure(int code, String msg);
    }

    public void outExit() {
        //不要清除session，这样再次登录时能够保留历史记录。如果需要清除掉本地历史记录和服务器信息这里使用true
        ChatManagerHolder.gChatManager.disconnect(true, false);
        SharedPreferences sp = MyApp.getContext().getSharedPreferences("config", Context.MODE_PRIVATE);
        sp.edit().clear().apply();
        OKHttpHelper.clearCookies();
        Intent intent = new Intent(MyApp.getContext(), SplashActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        MyApp.getContext().startActivity(intent);
    }

    @Deprecated //"已经废弃，请使用smsLogin"
    public void namePwdLogin(String account, String password, LoginCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/api/login";
        Map<String, Object> params = new HashMap<>();
        params.put("name", account);
        params.put("password", password);

        try {
            params.put("clientId", ChatManagerHolder.gChatManager.getClientId());
        } catch (Exception e) {
            e.printStackTrace();
            callback.onUiFailure(-1, "网络出来问题了。。。");
            return;
        }

        OKHttpHelper.post(url, params, new SimpleCallback<LoginResult>() {
            @Override
            public void onUiSuccess(LoginResult loginResult) {
                callback.onUiSuccess(loginResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                callback.onUiFailure(code, msg);
            }
        });
    }

    public void smsLogin(String phoneNumber, String authCode, String password, LoginCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/public/login";
        Map<String, Object> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        params.put("verifyCode", authCode);
        if (TextUtils.isEmpty(authCode)) {
            params.put("password", password);
        }

        try {
            params.put("clientId", ChatManagerHolder.gChatManager.getClientId());
        } catch (Exception e) {
            e.printStackTrace();
            callback.onUiFailure(-1, "网络出来问题了。。。");
            return;
        }


        OKHttpHelper.post(url, params, new SimpleCallback<LoginResult>() {
            @Override
            public void onUiSuccess(LoginResult loginResult) {
                callback.onUiSuccess(loginResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * 发送修改资金密码验证码
     *
     * @param phoneNumber
     * @param callback
     */
    public void forgetPayPassword(String phoneNumber, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/msm/private/forgetPayPassword";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        OKHttpHelper.get(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });

    }

    /**
     * 发送修改登录密码验证码
     *
     * @param phoneNumber
     * @param callback
     */
    public void forgetPassword(String phoneNumber, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/msm/private/forgetPassword";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        OKHttpHelper.get(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });

    }

    /**
     * 发送更换新手机验证码
     *
     * @param phoneNumber
     * @param callback
     */
    public void sendNewMobile(String phoneNumber, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/msm/private/sendNewMobile";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        OKHttpHelper.get(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });

    }

    /**
     * 发送更换旧手机验证码
     *
     * @param phoneNumber
     * @param callback
     */
    public void sendOldMobile(String phoneNumber, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/msm/private/sendOldMobile";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        OKHttpHelper.get(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });

    }

    /**
     * 发送登录 验证码
     *
     * @param phoneNumber
     * @param callback
     */
    public void requestAuthCode(String phoneNumber, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/msm/login";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        OKHttpHelper.get(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 修改资金密码
     *
     * @param phoneNumber 手机号码
     * @param password    密码
     * @param verifyCode  验证码
     * @param callback
     */
    public void replacePayPassowrd(String phoneNumber, String verifyCode, String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/replacePayPassowrd";
        Map<String, Object> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        params.put("verifyCode", verifyCode);
        params.put("password", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 修改登录密码
     *
     * @param phoneNumber 手机号码
     * @param password    密码
     * @param verifyCode  验证码
     * @param callback
     */
    public void replacePassowrd(String phoneNumber, String verifyCode, String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/replacePassowrd";
        Map<String, Object> params = new HashMap<>();
        params.put("mobile", phoneNumber);
        params.put("verifyCode", verifyCode);
        params.put("password", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 修改锁屏密码
     *
     * @param oldPassword
     * @param password
     * @param callback
     */
    public void replaceLockPassword(String oldPassword, String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/replaceLockPassword";
        Map<String, Object> params = new HashMap<>();
        params.put("oldPassword", oldPassword);
        params.put("password", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 设置锁屏密码
     *
     * @param callback 锁屏密码
     */
    public void addLockPassword(String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/addLockPassword";
        Map<String, Object> params = new HashMap<>();
        params.put("lockPassword", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 设置销毁密码
     */
    public void addDestroyPassword(String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/addDestroyPassword";
        Map<String, Object> params = new HashMap<>();
        params.put("destroyPassword", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 修改销毁密码
     *
     * @param oldPassword
     * @param password
     * @param callback
     */
    public void replaceDestroyPassword(String oldPassword, String password, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/replaceDestroyPassword";
        Map<String, Object> params = new HashMap<>();
        params.put("oldPassword", oldPassword);
        params.put("password", password);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     *
     */
    public void toTransferAccountDetail(String orderid, TransferAccountDetailCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/coin/toTransferAccountDetail?orderId=" + orderid;
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<TransferAccountDetailBean>() {
            @Override
            public void onUiSuccess(TransferAccountDetailBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code,msg);
            }
        });
    }


    /**
     * 设置解锁密码开关
     */
    public void lockPasswordEnable(SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/user/lockPasswordEnable";
        Map<String, Object> params = new HashMap<>();
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 设置销毁密码开关
     */
    public void destroyPasswordEnable(SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/user/destroyPasswordEnable";
        Map<String, Object> params = new HashMap<>();
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }


    /**
     * @param newMobile     新手机号
     * @param newVerifyCode 新手机验证码
     * @param oldVerifyCode 旧手机验证码
     * @param callback
     */
    public void replaceNewMobile(String newMobile, String newVerifyCode, String oldVerifyCode, SendCodeCallback callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/replaceNewMobile";
        Map<String, Object> params = new HashMap<>();
        params.put("newMobile", newMobile);
        params.put("newVerifyCode", newVerifyCode);
        params.put("oldVerifyCode", oldVerifyCode);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 销毁账号
     */
    public void destroyMobile(String payPassword, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/user/destroyMobile";
        Map<String, Object> params = new HashMap<>();
        params.put("payPassword", payPassword);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 输入销毁密码时调用销毁账号
     */
    public void validateDestroyPassword(String payPassword, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/user/validateDestroyPassword";
        Map<String, Object> params = new HashMap<>();
        params.put("destroyPassword", payPassword);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 判断是否为旧设备
     *
     * @param account 手机号
     */
    public void validateImei(String account, OphoneCallback ophoneCallback) {

        String url = Config.APP_SERVER_ADDRESS + "/public/validate";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", account);

        OKHttpHelper.get(url, params, new SimpleCallback<LoginPhoneResult>() {

            @Override
            public void onUiSuccess(LoginPhoneResult loginPhoneResult) {
                ophoneCallback.onUiSuccess(loginPhoneResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                ophoneCallback.onUiFailure(code, msg);
            }
        });
    }


    public void scanPCLogin(String token, ScanPCCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/public/scan/scan_pc/";
        url += "/" + token;
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("token", token);

        OKHttpHelper2.post(url, jsonObject.toString(), new SimpleCallback<PCSession>() {
            @Override
            public void onUiSuccess(PCSession pcSession) {
                if (pcSession.getStatus() == 1) {
                    callback.onUiSuccess(pcSession);
                } else {
                    callback.onUiFailure(pcSession.getStatus(), "");
                }
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    public void confirmPCLogin(String token, String userId, PCLoginCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/public/scan/confirm_pc";

        Map<String, Object> params = new HashMap<>(2);
        params.put("user_id", userId);
        params.put("token", token);
        OKHttpHelper2.post(url, params, new SimpleCallback<PCSession>() {
            @Override
            public void onUiSuccess(PCSession pcSession) {
                if (pcSession.getStatus() == 2) {
                    callback.onUiSuccess();
                } else {
                    callback.onUiFailure(pcSession.getStatus(), "");
                }
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    public void cancelPc(String token, PCLoginCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/public/scan/cancel_pc";

        Map<String, Object> params = new HashMap<>(2);
        params.put("token", token);
        OKHttpHelper2.post(url, params, new SimpleCallback<StatusResult2>() {
            @Override
            public void onUiSuccess(StatusResult2 pcSession) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    @Override
    public void getGroupAnnouncement(String groupId, AppServiceProvider.GetGroupAnnouncementCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/groupAnnouncement/get_group_announcement";

        Map<String, Object> params = new HashMap<>(2);
        params.put("groupId", groupId);
        OKHttpHelper.post(url, params, new SimpleCallback<GroupAnnouncement>() {
            @Override
            public void onUiSuccess(GroupAnnouncement announcement) {
                callback.onUiSuccess(announcement);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    @Override
    public void updateGroupAnnouncement(String groupId, String announcement, AppServiceProvider.UpdateGroupAnnouncementCallback callback) {
        //更新到应用服务，再保存到本地SP中
        String url = Config.APP_SERVER_ADDRESS + "/private/groupAnnouncement/put_group_announcement";

        Map<String, Object> params = new HashMap<>(2);
        params.put("groupId", groupId);
        params.put("author", ChatManagerHolder.gChatManager.getUserId());
        params.put("text", announcement);
        OKHttpHelper.post(url, params, new SimpleCallback<GroupAnnouncement>() {
            @Override
            public void onUiSuccess(GroupAnnouncement announcement) {
                callback.onUiSuccess(announcement);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    @Override
    public void uploadLog(SimpleCallback<String> callback) {
        List<String> filePaths = ChatManager.Instance().getLogFilesPath();
        if (filePaths == null || filePaths.isEmpty()) {
            if (callback != null) {
                callback.onUiFailure(-1, "没有日志文件");
            }
            return;
        }
        Context context = ChatManager.Instance().getApplicationContext();
        if (context == null) {
            if (callback != null) {
                callback.onUiFailure(-1, "not init");
            }
            return;
        }
        SharedPreferences sp = context.getSharedPreferences("log_history", Context.MODE_PRIVATE);

        String userId = ChatManager.Instance().getUserId();
        String url = Config.APP_SERVER_ADDRESS + "/logs/" + userId + "/upload";

        int toUploadCount = 0;
        Collections.sort(filePaths);
        for (int i = 0; i < filePaths.size(); i++) {
            String path = filePaths.get(i);
            File file = new File(path);
            if (!file.exists()) {
                continue;
            }
            // 重复上传最后一个日志文件，因为上传之后，还会追加内容
            if (!sp.contains(path) || i == filePaths.size() - 1) {
                toUploadCount++;
                OKHttpHelper.upload(url, null, file, MediaType.get("application/octet-stream"), new SimpleCallback<Void>() {
                    @Override
                    public void onUiSuccess(Void aVoid) {
                        if (callback != null) {
                            callback.onSuccess(url);
                        }
                        sp.edit().putBoolean(path, true).commit();
                    }

                    @Override
                    public void onUiFailure(int code, String msg) {
                        if (code == OUTEXIT) {
                            outExit();
                            return;
                        }
                        if (callback != null) {
                            callback.onUiFailure(code, msg);
                        }
                    }
                });
            }
        }
        if (toUploadCount == 0) {
            if (callback != null) {
                callback.onUiFailure(-1, "所有日志都已上传");
            }
        }
    }


    //0 个人 1群
    @Override
    public void sendAllReCallMessage(String toUser, String type, SimpleCallback<StatusResult> callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/user/sendAllReCallMessage";
        Map<String, Object> params = new HashMap<>();
        params.put("toUser", toUser);
        params.put("type", type);
        OKHttpHelper.post(url, params, callback);
    }


    public void recharge(String coinType, RechargeCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/recharge";
        Map<String, Object> params = new HashMap<>();
        params.put("coinType", coinType);
        OKHttpHelper.post(url, params, new SimpleCallback<RechargeBean>() {
            @Override
            public void onUiSuccess(RechargeBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * @param amount      金额
     * @param payPassword 密码
     * @param userId      对方iD
     * @param callback
     */
    public void transferAccount(String amount, String payPassword, String userId, String coinEnum, boolean pledge, SendCodeCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS +
                "/private/coin/transferAccount";
        Map<String, Object> params = new HashMap<>();
        params.put("amount", amount);
        params.put("payPassword", payPassword);
        params.put("toUserId", userId);
        params.put("coinEnum", coinEnum);
        params.put("pledge", pledge);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 发红包
     *
     * @param amount      红包总金额
     * @param number      红包数量
     * @param slogan      红包标语
     * @param toTarget    目标
     * @param payPassword 密码
     * @param callback
     */
    public void sendRedpage(String amount, String number, String slogan, String toTarget, String payPassword, SendCodeCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS +
                "/private/redPacket/send";
        Map<String, Object> params = new HashMap<>();
        params.put("amount", amount);
        params.put("payPassword", payPassword);
        params.put("number", number);
        params.put("slogan", slogan);
        params.put("toTarget", toTarget);
        params.put("fromUserId", ChatManager.Instance().getUserId());
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 抢红包
     *
     * @param hash 红包ID
     */
    public void grapRedpage(String hash, SendRedPageCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS +
                "/private/redPacket/grap";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    public void toWithdrawal(String coin, ToWithdrawalCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/toWithdrawal?coinType=" + coin;
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<ToWithdrawalBean>() {
            @Override
            public void onUiSuccess(ToWithdrawalBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    public void findLog(String hash, RedPageListCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/redPacket/findLog";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<RedPageListBean>() {
            @Override
            public void onUiSuccess(RedPageListBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * 进去挖矿列表
     *
     * @param callback
     */
    public void coinList(ConstListCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/coin/list";
        OKHttpHelper.get(url, null, new SimpleCallback<ConstListbean>() {
            @Override
            public void onUiSuccess(ConstListbean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * GET
     * <p>
     * 认证会员页
     *
     * @param callback
     */
    public void certificationList(CertificationListCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/certification/list";
        OKHttpHelper.get(url, null, new SimpleCallback<CertificationListbean>() {
            @Override
            public void onUiSuccess(CertificationListbean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * @param identitycardNumber
     * @param realName
     * @param imageBase64
     * @param callback
     */
    public void certificationSave(String identitycardNumber, String realName, String imageBase64, SimpleCallback callback) {

        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("identitycardNumber", identitycardNumber);
        jsonObject.addProperty("imageBase64", imageBase64);
        jsonObject.addProperty("realName", realName);

        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/certification/save";
        OKHttpHelper.post(url, jsonObject.toString(), new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });

    }

    /**
     * 收取挖矿
     */
    public void collect(String hash, ConstListCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/coin/collect";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<ConstListbean>() {
            @Override
            public void onUiSuccess(ConstListbean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    public void findMyAssets(AssetsCCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/user/findMyAssets?coinType=USDT";
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<AssetsBean>() {
            @Override
            public void onUiSuccess(AssetsBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    public void findMyAssets2(AssetsCCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/user/findMyAssets?coinType=FJ";
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<AssetsBean>() {
            @Override
            public void onUiSuccess(AssetsBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    public void exchangeFjList(AssetsCCallback callback) {
        //进入兑换飞机币列表
        String url = Config.APP_SERVER_ADDRESS + "/private/exchangeOrder/exchangeFjList";
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<AssetsBean>() {
            @Override
            public void onUiSuccess(AssetsBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    public void Moneylog(int page, String logEnum, logCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/log";
        Map<String, String> params = new HashMap<>();
        params.put("page", page + "");
        params.put("logEnum", logEnum);
        params.put("size", "10");
        OKHttpHelper.get(url, params, new SimpleCallback<MoneyFlowingWaterBean>() {
            @Override
            public void onUiSuccess(MoneyFlowingWaterBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * /private/coin/log
     * 获取FJ钱包日志
     *
     * @param page
     * @param callback
     */
    public void coinLog(int page, coinLogCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/coin/log";
        Map<String, String> params = new HashMap<>();
        params.put("page", page + "");
        params.put("size", "10");
        OKHttpHelper.get(url, params, new SimpleCallback<EarningsRecordBean>() {
            @Override
            public void onUiSuccess(EarningsRecordBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * /private/WithdrawOrder/fjList
     * 查询FJ提现列表
     *
     * @param page
     * @param callback
     */
    public void fjList(int page, withdrawalRecordCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/WithdrawOrder/fjList";
        Map<String, String> params = new HashMap<>();
        params.put("page", page + "");
        params.put("size", "10");
        OKHttpHelper.get(url, params, new SimpleCallback<WithdrawalRecordBean>() {
            @Override
            public void onUiSuccess(WithdrawalRecordBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    public void findDynamics(int page, FindDynamicCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/findDynamics";
        Map<String, String> params = new HashMap<>();
        params.put("page", page + "");
        params.put("size", "10");
        OKHttpHelper.get(url, params, new SimpleCallback<Feed>() {
            @Override
            public void onUiSuccess(Feed assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }


    public void releaseDynamics(String content, ReleaseDynamicsCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/releaseDynamics";
        OKHttpHelper.post(url, content, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * @param dynamicCommentId 评论的ID
     * @param content          回复内容
     * @param callback
     */
    public void dynamicsReply(String dynamicCommentId, String hash, String content, DynamicsReplyCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/dynamicsCommentReply";
        Map<String, Object> params = new HashMap<>();
        if (!TextUtils.isEmpty(dynamicCommentId)) {
            params.put("dynamicCommentId", dynamicCommentId);
        }
        params.put("hash", hash);
        params.put("content", content);
        OKHttpHelper.post(url, params, new SimpleCallback<DynamicsCommentsBean>() {
            @Override
            public void onUiSuccess(DynamicsCommentsBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * @param hash     朋友圈ID
     * @param callback
     */
    public void dynamicsLikes(String hash, DynamicsLikesCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/dynamicsLikes";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }
    /**
     * 删除评论
     */
    /**
     * @param dynamicsCommentId 评论ID
     * @param callback
     */
    public void removeDynamicsComment(String dynamicsCommentId, DynamicsLikesCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/removeDynamicsComment";
        Map<String, Object> params = new HashMap<>();
        params.put("dynamicsCommentId", dynamicsCommentId);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }

    /**
     * 删除朋友圈
     */
    public void removeDynamics(String hash, DynamicsLikesCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/removeDynamics";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }

    /**
     * 朋友圈设置为私有
     */
    public void updateDynamicsPrivate(String hash, DynamicsLikesCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/updateDynamicsPrivate";
        Map<String, Object> params = new HashMap<>();
        params.put("hash", hash);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    public void findDynamicsRate(FindDynamicsRateCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/dynamics/findDynamicsRate";

        OKHttpHelper.get(url, null, new SimpleCallback<RateBean>() {
            @Override
            public void onUiSuccess(RateBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    public void validateNetWork(FindNetWorkCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/netWork/validateNetWork";

        OKHttpHelper.get(url, null, new SimpleCallback<ValidateNetWorkBean>() {
            @Override
            public void onUiSuccess(ValidateNetWorkBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * 查询5级好友数量
     *
     * @param callback
     */
    public void findNetWorkCount(FindNetWorkCountCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/netWork/findNetWorkCount";

        OKHttpHelper.get(url, null, new SimpleCallback<NetWorkCountBean>() {
            @Override
            public void onUiSuccess(NetWorkCountBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * 根据电话号码获取ID
     *
     * @param mobile 手机号
     */
    public void getInfoByMobile(String mobile, InfoByMobileCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/user/getInfoByMobile";
        Map<String, String> params = new HashMap<>();
        params.put("mobile", mobile);
        OKHttpHelper.get(url, params, new SimpleCallback<UserBean>() {
            @Override
            public void onUiSuccess(UserBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    public void findNetWork(int page, String level, BuddyNetWorkCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/netWork/findNetWork";
        Map<String, String> params = new HashMap<>();
        params.put("page", page + "");
        params.put("level", level);
        params.put("size", "10");
        OKHttpHelper.get(url, params, new SimpleCallback<BuddyBean>() {
            @Override
            public void onUiSuccess(BuddyBean assetsBean) {
                callback.onUiSuccess(assetsBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * 加入关系网
     */
    public void addNetWork(String payPassword, String userId, DynamicsLikesCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/netWork/addNetWork";
        Map<String, Object> params = new HashMap<>();
        params.put("payPassword", payPassword);
        params.put("userId", userId);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }


    /**
     * 获取配置信息
     */
    public void configFind(String keyEnum, ConfigFindCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/config/find";
        Map<String, String> params = new HashMap<>();
        params.put("keyEnum", keyEnum);
        OKHttpHelper.get(url, params, new SimpleCallback<ConfigFindBean>() {
            @Override
            public void onUiSuccess(ConfigFindBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }

    /**
     * 添加提现地址
     */
    public void addWithdrawAddress(String address, String name, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/addWithdrawAddress";
        Map<String, Object> params = new HashMap<>();
        params.put("address", address);
        params.put("name", name);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * @param address     提现地址
     * @param amount      提现金额
     * @param payPassword 提现密码
     * @param callback
     */
    public void withdrawal(String address, String amount, String coin, String payPassword, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/withdrawal";
        Map<String, Object> params = new HashMap<>();
        params.put("address", address);
        params.put("amount", amount);
        params.put("payPassword", payPassword);
        params.put("coin", coin);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * @param id       提现id
     * @param callback
     */
    public void removeWithdrawAddress(String id, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/wallet/removeWithdrawAddress";
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * @param cardUser 名片 ID
     * @param toUser   接受人 ID
     * @param callback
     */
    public void sendVisitingCard(String cardUser, String toUser, String type, SendCodeCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/private/user/sendVisitingCard";
        Map<String, Object> params = new HashMap<>();
        params.put("cardUser", cardUser);
        params.put("toUser", toUser);
        params.put("type", type);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 检查更新
     */
    public void checkVersion(ChackVersionCallback callback) {
        String url = Config.APP_SERVER_ADDRESS + "/public/version/check";
        Map<String, Object> params = new HashMap<>();
        OKHttpHelper.post(url, params, new SimpleCallback<VersionBean>() {
            @Override
            public void onUiSuccess(VersionBean statusResult) {
                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }

    public void toTransferAccount(String type, String uid, TransferAccoountCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/coin/toTransferAccount?coinEnum=" + type + "&userId=" + uid;
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<TransferAccoountBean>() {
            @Override
            public void onUiSuccess(TransferAccoountBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    ///private/exchangeOrder/exchangeFj
    //进入兑换飞机币
    public void exchangeFj(String type, TransferAccoountCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS + "/private/exchangeOrder/exchangeFj?coinEnum=" + type;
        Map<String, String> params = new HashMap<>();
        OKHttpHelper.get(url, params, new SimpleCallback<TransferAccoountBean>() {
            @Override
            public void onUiSuccess(TransferAccoountBean rechargeBean) {
                callback.onUiSuccess(rechargeBean);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(-1, msg);
            }
        });
    }

    /**
     * @param payPassword 密码
     * @param callback
     */
    public void exchangeFjSave(String num, String payPassword, String coinEnum, boolean pledge, SendCodeCallback callback) {
        //从SP中获取到历史数据callback回去，然后再从网络刷新
        String url = Config.APP_SERVER_ADDRESS +
                "/private/exchangeOrder/exchangeFjSave";
        Map<String, Object> params = new HashMap<>();
        params.put("num", num);
        params.put("payPassword", payPassword);
        params.put("coinEnum", coinEnum);
        params.put("pledge", pledge);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {
                callback.onUiSuccess();
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(msg);
            }
        });
    }

    /**
     * 删除好友相关
     */
    @Override
    public void deleteFriendsRelevant(String friendsUserId, SimpleCallback<StatusResult> callback) {

        String url = Config.APP_SERVER_ADDRESS + "/private/user/deleteFriendsRelevant";
        Map<String, Object> params = new HashMap<>();
        params.put("friendsUserId", friendsUserId);
        OKHttpHelper.post(url, params, new SimpleCallback<StatusResult>() {
            @Override
            public void onUiSuccess(StatusResult statusResult) {

                callback.onUiSuccess(statusResult);
            }

            @Override
            public void onUiFailure(int code, String msg) {
                if (code == OUTEXIT) {
                    outExit();
                    return;
                }
                callback.onUiFailure(code, msg);
            }
        });
    }
}
